﻿// ***********************************************************************
// Assembly         : OSS.Earth
// Author           : tian_
// Created          : 02-04-2020
//
// Last Modified By : tian_
// Last Modified On : 02-04-2020
// ***********************************************************************
// <copyright file="OpenEarthFormWithWebDataCmd.cs" company="">
//     Copyright ©  2017
// </copyright>
// <summary></summary>
// ***********************************************************************

using System;
using System.Windows.Forms;
using OSS.Earth.Properties;
using ZFGK.Addins;
using ZFGK.osgEarth.PlatformGUI.Commands.ImageLayerCmds;
using ZFGK.osgEarth.UI;
using ZFGK.osgEarth.Web;
using ZfWebEarth;

namespace OSS.Earth.Commands
{
    /// <summary>
    /// Class OpenEarthFormWithWebDataCmd.
    /// </summary>
    /// <seealso cref="ZFGK.Addins.IExtendCommand" />
    public class OpenEarthFormWithWebDataCmd : IExtendCommand
    {
        /// <summary>
        /// Executes the specified command data.
        /// </summary>
        /// <param name="cmdData">The command data.</param>
        /// <param name="message">The message.</param>
        /// <returns>CmdResult.</returns>
        public CmdResult Execute(ExtendCmdData cmdData, ref string message)
        {
            var mainRibbonForm = cmdData.MainForm as Form;

            var osgEarthForm = new OsgEarthViewForm();
            osgEarthForm.Icon = Resources.network_earth;
            osgEarthForm.Text = "数字地球";
            osgEarthForm.WindowState = FormWindowState.Maximized;
            osgEarthForm.MdiParent = mainRibbonForm;

            var googleEarthElevationeLayer = OeWebLayerUtil.CreateGoogleEarthElevationeLayer();
            googleEarthElevationeLayer.Name = "GoogleEarthElevationeLayer";
            osgEarthForm.OsgEarthViewCtrl.OsgEarthObj.MapNode.getMap().addLayer(googleEarthElevationeLayer);
            osgEarthForm.Shown += delegate(object sender, EventArgs args)
            {
                // 显示谷歌印象和路网
                AddinManager.AddinService.TryRunCmd(new CmdInfo(typeof(UpdateImageLayerCmd), SatelliteImageType.GOOGLE_EARTH_TILE));
            };
            osgEarthForm.Show();
            return CmdResult.Succeed;
        }
    }
}
